<template lang="html">
  <div>
    <div class="header">
      <img src="@/assets/images/back.png" @click="back">
      <span>{{ $store.state.news.channel }}新闻</span>
      <span />
    </div>
    <div class="content">
      <div ref="container" class="container">
        <div class="title">{{ newsData && newsData.title }}</div>
        <div class="message">
          <span>{{ newsData && newsData.time }}</span>
        </div>
        <img :src="newsData && newsData.pic">
        <div class="newsContent" v-html="newsData && newsData.content" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  computed: {
    newsData() {
      return this.$store.state.news.newsData[this.$store.state.news.newsIndex]
    }
  },
  methods: {
    back() {
      this.$router.back()
    }
  }
}
</script>

<style lang="css" scoped>
.header {
  width: 100%;
  height: 1.33rem;
  background-color: #d43d3d;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
}
.header img {
    width: 0.67rem;
    height: 0.67rem;
    cursor: pointer;
}
.content {
  position: relative;
  top: 1.33rem;
  height:calc(100vh - 1.33rem - 49px);
  overflow-y:auto;
}
.container {
  margin: 20px;
}
.title {
  font-size: 24px;
  font-weight: bold;
  text-align: center;
}
.message {
  text-align: center;
  margin: 20px 0;
  color: #888;
}
.message span:last-child {
  margin-left: 10px;
}
.container img {
  width: 100%;
  margin-bottom: 20px;
}
.newsContent {
  font-size: 18px;
  line-height: 30px;
}
</style>
